package day02;

import java.util.Scanner;

import org.junit.Test;

/**
 * 测试正则表达式，并尝试编写规则: 电话号码可能有3-4位区号，
 * 7-8位号码:0415-5561111
 * @author Bonnie
 *
 */
public class Test06 {
	@Test
	public void test() {
		Scanner console = new Scanner(System.in);
		System.out.print("请输入电话号码：");
		String phone = console.nextLine();
		if (phone.matches("^\\d{3,4}\\-\\d{7,8}$")) {// ^\d{3,4}\-\d{7,8}$
			System.out.println("电话号码格式正确！");
		} else {
			System.out.println("电话号码格式错误！");
		}
		console.close();
	}
}
